home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bdoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  5.5 KB  |  230 lines

  1. /*
  2.  *
  3.  * $Id: k3bdoc.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef K3BDOC_H
  18. #define K3BDOC_H
  19.  
  20. #ifdef HAVE_CONFIG_H
  21. #include <config.h>
  22. #endif
  23.  
  24. // include files for QT
  25. #include <qobject.h>
  26. #include <qstring.h>
  27. #include <qptrlist.h>
  28.  
  29.  
  30. // include files for KDE
  31. #include <kurl.h>
  32. #include <kio/global.h>
  33. #include "k3b_export.h"
  34.  
  35. // forward declaration of the K3b classes
  36. class QTimer;
  37. class KTempFile;
  38. class K3bBurnJob;
  39. class QDomDocument;
  40. class QDomElement;
  41. class KConfig;
  42. class KActionCollection;
  43. class K3bJobHandler;
  44.  
  45.  
  46. namespace K3bDevice {
  47.   class Device;
  48. }
  49. namespace K3b {
  50.   class Msf;
  51. }
  52.  
  53. /**
  54.  * K3bDoc is the base document class.
  55.  * It handles some general settings.
  56.  */
  57. class LIBK3B_EXPORT K3bDoc : public QObject
  58. {
  59.   Q_OBJECT
  60.  
  61.  public:
  62.   K3bDoc( QObject* = 0 );
  63.   virtual ~K3bDoc();
  64.  
  65.   enum DocType { 
  66.     AUDIO = 1, 
  67.     DATA, 
  68.     MIXED, 
  69.     VCD, 
  70.     MOVIX,
  71.     MOVIX_DVD,
  72.     DVD,
  73.     VIDEODVD 
  74.   };
  75.  
  76.   virtual int type() const { return m_docType; }
  77.  
  78.   /**
  79.    * \return A name for the project which might for example be used as a suggestion for a file name
  80.    *         when saving. The default implementation extracts a name from the URL.
  81.    */
  82.   virtual QString name() const;
  83.  
  84.   /**
  85.    * \return A string representation of the document type.
  86.    */
  87.   virtual QString typeString() const = 0;
  88.  
  89.   /** 
  90.    * returns the view widget set with setView() or null if none has been set.
  91.    */
  92.   QWidget* view() const { return m_view; }
  93.  
  94.   /**
  95.    * Just for convenience to make an easy mapping from doc to GUI possible.
  96.    */
  97.   void setView( QWidget* v ) { m_view = v; }
  98.  
  99.   /** 
  100.    * sets the modified flag for the document after a modifying action on the view connected to the document.
  101.    */
  102.   virtual void setModified( bool m = true );
  103.  
  104.   /** 
  105.    * returns if the document is modified or not. Use this to determine 
  106.    * if your document needs saving by the user on closing.
  107.    */
  108.   virtual bool isModified() const { return m_modified; }
  109.  
  110.   /**
  111.    * Subclasses should call this when reimplementing.
  112.    * Sets some defaults.
  113.    */
  114.   virtual bool newDocument();
  115.  
  116.   /**
  117.    * Load a project from an xml stream.
  118.    *
  119.    * This is used to load/save k3b projects. 
  120.    */
  121.   virtual bool loadDocumentData( QDomElement* root ) = 0;
  122.  
  123.   /**
  124.    * Save a project to an xml stream.
  125.    *
  126.    * This is used to load/save k3b projects. 
  127.    */
  128.   virtual bool saveDocumentData( QDomElement* docElem ) = 0;
  129.  
  130.   /** returns the KURL of the document */
  131.   const KURL& URL() const;
  132.   /** sets the URL of the document */
  133.   virtual void setURL( const KURL& url );
  134.  
  135.   int writingMode() const { return m_writingMode; }
  136.   bool dummy() const { return m_dummy; }
  137.   bool onTheFly() const { return m_onTheFly; }
  138.   bool removeImages() const { return m_removeImages; }
  139.   bool onlyCreateImages() const { return m_onlyCreateImages; }
  140.   int copies() const { return m_copies; }
  141.   int speed() const { return m_speed; }
  142.   K3bDevice::Device* burner() const { return m_burner; }
  143.   virtual KIO::filesize_t size() const = 0;
  144.   virtual K3b::Msf length() const = 0;
  145.  
  146.   // FIXME: rename this to something like imagePath
  147.   const QString& tempDir() const { return m_tempDir; }
  148.  
  149.   virtual int numOfTracks() const { return 1; }
  150.  
  151.   /**
  152.    * Create a new BurnJob to burn this project. It is not mandatory to use this
  153.    * method. You may also just create the BurnJob you need manually. It is just 
  154.    * easier this way since you don't need to distinguish between the different
  155.    * project types.
  156.    */
  157.   virtual K3bBurnJob* newBurnJob( K3bJobHandler*, QObject* parent = 0 ) = 0;
  158.  
  159.   int writingApp() const { return m_writingApp; }
  160.   void setWritingApp( int a ) { m_writingApp = a; }
  161.  
  162.   /**
  163.    * @return true if the document has successfully been saved to a file
  164.    */
  165.   bool isSaved() const { return m_saved; }
  166.  
  167.   /**
  168.    * Used for session management. Use with care.
  169.    */
  170.   void setSaved( bool s ) { m_saved = s; }
  171.  
  172.  signals:
  173.   void changed();
  174.   void changed( K3bDoc* );
  175.  
  176.  public slots:
  177.   void setDummy( bool d );
  178.   void setWritingMode( int m ) { m_writingMode = m; }
  179.   void setOnTheFly( bool b ) { m_onTheFly = b; }
  180.   void setSpeed( int speed );
  181.   void setBurner( K3bDevice::Device* dev );
  182.   void setTempDir( const QString& dir ) { m_tempDir = dir; }
  183.   void setRemoveImages( bool b ) { m_removeImages = b; }
  184.   void setOnlyCreateImages( bool b ) { m_onlyCreateImages = b; }
  185.   void setCopies( int c ) { m_copies = c; }
  186.  
  187.   /**
  188.    * the default implementation just calls addUrls with
  189.    * list containing the url
  190.    */
  191.   virtual void addUrl( const KURL& url );
  192.   virtual void addUrls( const KURL::List& urls ) = 0;
  193.  
  194.  protected:
  195.   int m_docType;
  196.  
  197.   bool saveGeneralDocumentData( QDomElement* );
  198.  
  199.   bool readGeneralDocumentData( const QDomElement& );
  200.  
  201.  private slots:
  202.   void slotChanged();
  203.  
  204.  private:
  205.   /** the modified flag of the current document */
  206.   bool m_modified;
  207.   KURL doc_url;
  208.  
  209.   QWidget* m_view;
  210.  
  211.   QString m_tempDir;
  212.   K3bDevice::Device* m_burner;
  213.   bool m_dummy;
  214.   bool m_onTheFly;
  215.   bool m_removeImages;
  216.   bool m_onlyCreateImages;
  217.   int  m_speed;
  218.  
  219.   /** see k3bglobals.h */
  220.   int m_writingApp;
  221.  
  222.   int m_writingMode;
  223.  
  224.   int m_copies;
  225.  
  226.   bool m_saved;
  227. };
  228.  
  229. #endif // K3BDOC_H
  230.